﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

namespace FoundationLib.Ifc.Logging.Configuration
{
	/// <summary>
	/// This class represents a collection of logger configuration elements.
	/// </summary>
	public class LoggerCollection : ConfigurationElementCollection, IEnumerable<LoggerConfigElement>
	{
		/// <summary>
		/// Creates a new <see cref="LoggerCollection"/>.
		/// </summary>
		public LoggerCollection()
			: base()
		{
		}

		/// <see cref="IEnumerable{T}.GetEnumerator()"/>
		public new IEnumerator<LoggerConfigElement> GetEnumerator()
		{
			for (int i = 0; i < base.Count; i++)
				yield return this.BaseGet(i) as LoggerConfigElement;
		}

		
		/// <see cref="ConfigurationElementCollection.CreateNewElement()"/>
		protected override ConfigurationElement CreateNewElement()
		{
			return (new LoggerConfigElement());
		}

		/// <see cref="ConfigurationElementCollection.GetElementKey(ConfigurationElement)"/>
		protected override object GetElementKey(ConfigurationElement element)
		{
			return ((LoggerConfigElement)element).Name;
		}
	}
}
